<?php
namespace SinoPHP\BbdBoss\Model;

use Upfor\UpforPHP\Model;


/**
* 平台域名线路
*/

class  PlatDomainLine extends  Model{

    /*
     *初始化操作
     * */

    public function __construct() {
        parent::__construct();
    }

    /**
     * 获取IP列表
     *
     * @param string $fields
     * @param string $condition
     * @param null   $limit
     * @param null   $offset
     * @return array
     */
    public function getLineList($fields = '', $condition = '', $limit = null, $offset = null) {
        //构建sql
        $sql = "SELECT 
                  {$fields} 
                FROM 
                  `plat_domain_line`
                INNER JOIN `plat_domain` ON plat_domain_line.plat_domain_id = plat_domain.plat_domain_id
                WHERE plat_domain_line.is_delete = 0  AND plat_domain_line.policy_id > 0 ";

        $condition && $sql .= " AND " . $condition;
        if ($limit) {
            $sql .= "LIMIT {$offset},{$limit}";
        }
        $data = $this->db->query($sql);

        return $data;
    }

    public function getBatchLine($ids, $fields = 'domain_dnspod_line.id, domain_dnspod_line.line_name', $limit = null, $offset = null) {
        $sql = "SELECT 
                  {$fields} 
                FROM 
                  `plat_domain_line`
                INNER JOIN `domain_dnspod_line` ON plat_domain_line.record_line_id = domain_dnspod_line.id
                WHERE domain_dnspod_line.status = 1  AND plat_domain_line.plat_domain_line_id in ({$ids}) ";
        if ($limit) {
            $sql .= "LIMIT {$offset},{$limit}";
        }
        $data = $this->db->query($sql);

        return $data;
    }

}
